From 3a44cc26138189c96b2772781987a9c7d9f43394 Mon Sep 17 00:00:00 2001 From: "kaf24@firebug.cl.cam.ac.uk" Date: Tue, 18 Oct 2005 11:04:48 +0100 Subject: [PATCH] Allow interdomain channels to bind DOMID_SELF to DOMID_SELF. Signed-off-by: Steve King --- xen/common/event_channel.c | 9 +++++++-- xen/include/public/event_channel.h | 3 +++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/xen/common/event_channel.c b/xen/common/event_channel.c index 8dd52eb49f..f0feb65fd8 100644 --- a/xen/common/event_channel.c +++ b/xen/common/event_channel.c @@ -89,7 +89,8 @@ static long evtchn_alloc_unbound(evtchn_alloc_unbound_t *alloc) chn = evtchn_from_port(d, port); chn->state = ECS_UNBOUND; - chn->u.unbound.remote_domid = alloc->remote_dom; + if ( (chn->u.unbound.remote_domid = alloc->remote_dom) == DOMID_SELF ) + chn->u.unbound.remote_domid = current->domain->domain_id; alloc->port = port; @@ -107,9 +108,13 @@ static long evtchn_bind_interdomain(evtchn_bind_interdomain_t *bind) struct evtchn *lchn, *rchn; struct domain *ld = current->domain, *rd; int lport, rport = bind->remote_port; + domid_t rdom = bind->remote_dom; long rc = 0; - if ( (rd = find_domain_by_id(bind->remote_dom)) == NULL ) + if ( rdom == DOMID_SELF ) + rdom = current->domain->domain_id; + + if ( (rd = find_domain_by_id(rdom)) == NULL ) return -ESRCH; /* Avoid deadlock by first acquiring lock of domain with smaller id. */ diff --git a/xen/include/public/event_channel.h b/xen/include/public/event_channel.h index 18bbd97c86..1de1057512 100644 --- a/xen/include/public/event_channel.h +++ b/xen/include/public/event_channel.h @@ -15,6 +15,7 @@ * is allocated in and returned as . * NOTES: * 1. If the caller is unprivileged then must be DOMID_SELF. + * 2. may be DOMID_SELF, allowing loopback connections. */ #define EVTCHNOP_alloc_unbound 6 typedef struct evtchn_alloc_unbound { @@ -30,6 +31,8 @@ typedef struct evtchn_alloc_unbound { * a port that is unbound and marked as accepting bindings from the calling * domain. A fresh port is allocated in the calling domain and returned as * . + * NOTES: + * 2. may be DOMID_SELF, allowing loopback connections. */ #define EVTCHNOP_bind_interdomain 0 typedef struct evtchn_bind_interdomain { -- 2.30.2